package com.example.shiXun.dao;

import com.example.shiXun.domain.SysRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface RoleDao {

    @Select("select * from sys_role t")
    List<SysRole> getAllRole();

    @Select("select count(*) from sys_role ")
    Long countAllRole();

    @Select("select * from sys_role limit #{startPosition}, #{limit}")
    List<SysRole> getAllRoleByPage(@Param("startPosition") Integer offset, @Param("limit") Integer limit);

    @Select("select count(*) from sys_role t where t.name like '%${roleName}%'")
    Long countRoleByFuzzyName(@Param("roleName") String roleName);

    @Select("select * from sys_role t where t.name like '%${roleName }%' limit #{startPosition}, #{limit}")
    List<SysRole> getRoleByFuzzyNamePage(@Param("roleName") String roleName, @Param("startPosition") Integer offset, @Param("limit") Integer limit);

    int saveRole(SysRole role);

    int update(SysRole role);

    @Select("select * from sys_role where id = #{id}")
    SysRole getById(@Param("id") Integer id);

    @Delete("delete from sys_role where id = #{id}")
    int delete(Integer id);
}
